home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / Comet.3.0.7 Folder / ibm-host-software / DOWNLOAD.EXEC < prev    next >
Text File  |  1988-05-24  |  5KB  |  139 lines

  1. /*
  2. Use this exec to transfer CMS files to your IBM PC or Mac via FT3270 or FTC19.
  3.  
  4. SYNTAX:
  5.       DOWNLOAD fn ft <fm <micro_filespec>> <( <REPlace> <BINary|TEXt> <)> >
  6.  
  7. Notes:
  8.    1) Default filemode is A and is required if micro_filespec is used.
  9.    2) Default micro_filespec is the concatenation fn.ft
  10.    3) Wildcards may be used in the CMS and/or the microcomputer filespecs.
  11.       Forward slashes may be typed in place of backward slashes which are
  12.       frequently used as line end characters.
  13.    4) The REPLACE option means the local file will be replaced with the
  14.       transferred one. The default is to return an error if a local file with
  15.       that name exists.
  16.    5) The BINARY option means that a binary translation will take place with no
  17.       ebcdic to ASCII translation and no CR/LF's inserted in the local file.
  18.    6) The TEXT option means that the program will perform the ebcdic/ASCII
  19.       translation, strip trailing blanks off fixed length records, and insert
  20.       CR/LF in the local file.
  21.    7) The default is to let the micro decide whether to make the transfer TEXT
  22.       or BINARY and so inform the CMS program.
  23.  
  24. */
  25.  
  26. /* modified for mac to preserve slash marks kevin 11/3/87 */
  27. /* 5-5-88 Rich K split path/name based on forward or backslashes */
  28. /* 5-13-88 RICH K. FIX BUG WHEN RDR FILE ARRIVES SPOOLED TO CURRENT */
  29. /*                 READER SETTING */
  30.  
  31. address 'COMMAND'
  32.  
  33. /* Parse the arguments and see if help is obviously needed */
  34.  
  35. parse upper arg FN FT FM .     '(' opts ')'
  36. parse       arg .  .  .  FSpec '('/* get FSpec in mixed case */
  37.  
  38. if FN = '' | FN = '?' then signal help
  39. if FT = '' | length( FM ) > 2
  40. then do
  41.   say 'Invalid CMS file specification';  exit 1
  42.   end
  43.  
  44. /*
  45. Parse up the micro filespec into drive&path, name, and extension.  The
  46. drive&path part is always used, but the file name and/or extension will
  47. be derived from the CMS FN and/or FT if '*' is used or the whole thing
  48. is blank.
  49. */
  50.  
  51. FSpec   = strip( translate( FSpec, ' ', '"' ) ) /* / = \ & remove "s */
  52. NamePos = max( lastpos( ':', FSpec ), lastpos( '\', FSpec ) )
  53. NamePos = max( NamePos, lastpos( '/', FSpec ) )
  54. path    = left(   FSpec, NamePos )     /* split the drive & path */
  55. FSpec   = substr( FSpec, NamePos+1 )   /* from the filename */
  56.  
  57. if FSpec = '' then FSpec = '*.*'       /* blank filename = use default */
  58.  
  59. do i = 1 to 2                          /* check for wildcards */
  60.   StarPos.i = pos( '*', FSpec )
  61.   if StarPos.i > 0 then FSpec = delstr( FSpec, StarPos.i, 1 )
  62.   end
  63.  
  64. SepPos = verify( FSpec, ' .', 'MATCH' )
  65. if StarPos.1 > 0 & StarPos.2 = 0,      /* just one wildcard... */
  66.    & StarPos.1 > SepPos & SepPos > 0   /* after a seperator character? */
  67.   then do                              /* then make FT, not FN, wild */
  68.     StarPos.2 = StarPos.1
  69.     StarPos.1 = 0
  70.     end
  71.  
  72. /* Parse the options string */
  73.  
  74. rep = 'N'                              /* set default flags */
  75. bin = 'D'
  76.  
  77. do while( opts ^= '' )
  78.   parse var opts opt opts              /* get the next option word */
  79.  
  80.   select
  81.     when abbrev( 'REPLACE', opt, 3 ) then rep = 'R' /* REPlace */
  82.     when abbrev( 'BINARY',  opt, 3 ) then bin = 'B' /* BINary */
  83.     when abbrev( 'TEXT',    opt, 3 ) then bin = 'T' /* TEXt */
  84.     otherwise do
  85.       say "Invalid option: '"opt"'";  exit 1
  86.       end
  87.     end                                /* end select */
  88.   end                                  /* end do */
  89.  
  90. ConByte = 'D' || bin || rep            /* generate control byte */
  91.  
  92. /* Remember whether messages etc. were on or off */
  93.  
  94. 'MAKEBUF'                              /* start a new console stack */
  95. BufNum = rc
  96.  
  97. 'CPSTACK LIFO QUERY SET'
  98. pull . ; pull . ; pull .
  99. pull 'IMSG' imsg ',' .
  100. pull . ; pull .
  101. pull 'MSG' msg ',' . 'WNG' wng ',' .
  102.  
  103. 'CPSTACK Q C'                               /* CHECK READER SETTING */
  104. pull 'RDR' rdrnum 'CL' rdrcl rdrcont rdrhold rdreof rdrready
  105. 'CP NOTREADY C'
  106.  
  107. /* Run the file transfer program to download the file(s) */
  108.  
  109. 'LISTFILE' FN FT FM '(STACK'           /* get file name(s) */
  110. if rc ^= 0 then say 'CMS file' FN FT FM 'not found'
  111.  
  112. do queued() while( rc = 0 )            /* loop thru each file stacked */
  113.    pull FN FT FM .
  114.  
  115.    MicroSpec = FSpec
  116.    if StarPos.2 > 0 then MicroSpec = insert( FT, MicroSpec, StarPos.2-1 )
  117.    if StarPos.1 > 0 then MicroSpec = insert( FN, MicroSpec, StarPos.1-1 )
  118.  
  119.    'FT3270 "'path||MicroSpec'"' ConByte FN FT FM /* do the download */
  120.    end                                 /* end do loop */
  121.  
  122. /* Restore msg processing & exit */
  123.  
  124. rrc = rc                               /* save RC from last command */
  125. 'CP SET MSG'  msg                      /* restore settings */
  126. 'CP SET WNG'  wng
  127. 'CP SET IMSG' imsg
  128. if rdrready = 'READY' then 'CP READY C'
  129. 'DROPBUF' BufNum                       /* drop our console stack */
  130. exit rrc
  131.  
  132. /* Help screen -- Show the comments at the front of this file */
  133.  
  134. Help:
  135. 'VMFCLEAR'
  136. do i = 2 while( sourceline( i ) ^= '*/' )
  137.    say sourceline( i )
  138.    end
  139.